import {Component} from "react";
import {Text, View} from "@tarojs/components";
import Taro from "@tarojs/taro";

export default class ClassType extends Component {
  state = {
    list: [
      {
        title: '午托',
        wdm: 10,
        qd: 5,
        lx: 6
      }
    ]
  }
  handelCliLi = function (e) {
    console.log('', e)
    Taro.navigateTo({
      url: '/pages/classList/index?id=1',
      events: {
        // 为指定事件添加一个监听器，获取被打开页面传送到当前页面的数据
        acceptDataFromOpenedPage: function (data) {
          console.log(data)
        },
        someEvent: function (data) {
          console.log(data)
        }
      },
      success: function (res) {
        // 通过eventChannel向被打开页面传送数据
        res.eventChannel.emit('acceptDataFromOpenerPage', {data: 'test'})
      }
    }).then(() => {})
  }
    render() {
    const {list} = this.state
      return (
        <View className='classTypebox'>
          <View className='ul'>
            {
              list.map((item, index) =>
              <View key={index} className='li' onClick={() => this.handelCliLi(item)}>
                <View className='title'>
                  {item.title}
                </View>
                <View className='nrbox'>
                  <View className='span'>
                    <Text className='min-title'>未点名：</Text>
                    <Text className='num'>{item.wdm}</Text>
                  </View>
                  <View className='span'>
                    <Text className='min-title'>签到：</Text>
                    <Text className='num'>{item.qd}</Text>
                  </View>
                  <View className='span'>
                    <Text className='min-title'>留校：</Text>
                    <Text className='num'>{item.lx}</Text>
                  </View>
                </View>
              </View>)
            }
          </View>
        </View>
      )
    }
}
